{{ $newsPath := (printf "data/%s/news/news.toml" $.Language.Lang) }}

{{ $newsData := "" }}
{{ if (fileExists $newsPath) -}}
  {{ $data := index .Site.Data $.Language.Lang }}
  {{ $newsData = $data.news }}
{{ else }}
  {{ $dataDefaultLanguage := index .Site.Data .Sites.First.Language.Lang }}
  {{ $newsData = $dataDefaultLanguage.news }}
{{ end }}

{{ with $newsData.news }}
  {{ $newsCounter := 0 }}
  {{ $newsDayCounter := 1 }}
  {{ $newsDayPrev := false }}
  {{ range (sort .news "date" "desc") }}
    {{ if lt $newsCounter 6 }}
      {{ $newsDayCur := dateFormat "2006-01-02" .date }}
      {{ if eq $newsDayCur $newsDayPrev }}
        {{ $newsDayCounter = add $newsDayCounter 1 }}
      {{ else }}
        {{ $newsDayCounter = 1 }}
      {{ end }}
    <p>
      <span class="txtdate">{{ dateFormat "2006-01-02" .date }}</span>
      <br />
      <a href="{{.Site.BaseURL | relLangURL }}news/newsflash/#{{ dateFormat "2006-01-02" .date }}:{{ $newsDayCounter }}">
      {{ if .title }}
        {{ $title := replaceRE "<a .*\">" "" .title }}
        {{ $title = replaceRE "</a>" "" $title }}
        {{ $title | safeHTML }}
      {{ else }}
        {{ $description := replaceRE "<a .*\">" "" .description }}
        {{ $description = replaceRE "</a>" "" $description }}
        {{ $description | safeHTML }}
      {{ end }}
      </a>
    </p>
      {{ $newsCounter = add $newsCounter 1 }}
      {{ $newsDayPrev = $newsDayCur }}
    {{ end }}
  {{ end }}
{{ end }}
